<!-- 选择指标弹窗 -->
<template>
    <div class="select-index-dialog">
        <el-dialog title="选择指标" :visible.sync="dialogVisible" width="600px" :close-on-click-modal="false">
            <div class="select-index">
                <Tree ref="indexDataTreeRef" :isGeneralFolderAndFile="true" :treeData="indexDataList"
                    @nodeClick="nodeClick"></Tree>
            </div>

            <span slot="footer" class="dialog-footer">
                <el-button class="jtyj-btn-cancel" @click="dialogVisible = false">取 消</el-button>
                <el-button class="jtyj-btn-primary" @click="submit">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import { getScenarioTree } from "@/api/myspace/scenario-edit-tool/scenario-edit";
import Tree from "@/components/LeftTree/tree.vue";
export default {
    name: "SelectIndexDialog",
    data() {
        return {
            dialogVisible: false,
            indexDataList: [],
            selectedNodeInfo: null, // 当前选中节点的信息
        }
    },
    components: {
        Tree
    },
    created() {
        this.getIndexTree();
    },
    methods: {
        getIndexTree() {
            getScenarioTree().then((response) => {
                if (response.code === 200) {
                    this.indexDataList = response.data[0].commonTreeList;
                }
            });
        },
        nodeClick(node) {
            this.selectedNodeInfo = node;
        },
        submit() {
            console.log(this.activeName);
            if (this.selectedNodeInfo) {
                console.log("在线选择提交");
                this.dialogVisible = false;
            } else{
                console.log("选择指标后提交");
            }
        }
    },
    mounted() {

    }
}
</script>

<style lang="scss" scoped>
.select-index-dialog {
    .select-index {
        width: 550px;
        height: 600px;

        .upload-file {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
    }
}
</style>